//
//  AccountSecurityViewController.m
//  StandardizedProduct
//
//  Created by 宁宁 on 16/7/27.
//  Copyright © 2016年 ym. All rights reserved.
//

#import "AccountSecurityViewController.h"

#import "ChangePasswordViewController.h"//修改密码Controller

@interface AccountSecurityViewController ()

@end

@implementation AccountSecurityViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    [self setNav];
}

- (void)setNav{
    self.title = @"账户安全";
    
    UIBarButtonItem *save = [[UIBarButtonItem alloc] initWithTitle:@"保存" style:0 target:self action:@selector(saveModify)];
    self.navigationItem.rightBarButtonItem = save;
    
    UIBarButtonItem *back = [[UIBarButtonItem alloc] init];
    back.title = @"";
    self.navigationItem.backBarButtonItem = back;
}

//保存
- (void)saveModify{
    UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"是否确认保存修改?" message:nil preferredStyle:UIAlertControllerStyleAlert];
    
    UIAlertAction *cancel = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:nil];
    [alert addAction:cancel];
    
    UIAlertAction *save = [UIAlertAction actionWithTitle:@"保存" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
        NSLog(@"保存");
        [self.navigationController popViewControllerAnimated:YES];
    }];
    [alert addAction:save];
    
    [self presentViewController:alert animated:YES completion:nil];
}

//修改登录密码
- (IBAction)ModifyLoginPwd:(id)sender {
    ChangePasswordViewController *change = [[ChangePasswordViewController alloc] init];
    [self.navigationController pushViewController:change animated:YES];
}

//修改支付密码
- (IBAction)ModifyPayPwd:(id)sender {
}

//退出当前账号
- (IBAction)quit:(id)sender {
    NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
    [defaults removeObjectForKey:@"Id"];
    [defaults removeObjectForKey:@"UserName"];
    [defaults removeObjectForKey:@"CartNum"];
    [defaults removeObjectForKey:@"Password"];
    [EBUtility prompt:@"账号已退出" with:self];
    [self.navigationController popToRootViewControllerAnimated:YES];
}



@end
